package entity;

public class Student extends Person {
    private Course course;

    // 子类构造方法，使用super调用父类构造方法
    public Student(String id, String name, String gender) {
        super(id, name, gender);
    }

    public void selectCourse(Course course) {
        this.course = course;
        System.out.println(name + " 选了 " + course.getName() + " 课程");
    }

    public void dropCourse() {
        if (course != null) {
            System.out.println(name + " 退了 " + course.getName() + " 课程");
            course = null;
        } else {
            System.out.println(name + " 没有选课，无法退课");
        }
    }

    // 重写父类的打印工作单方法
    @Override
    public void printSchedule() {
        System.out.println("=== 学生课表 ===");
        printInfo();
        if (course != null) {
            System.out.println("课程名称：" + course.getName());
            System.out.println("上课地点：" + course.getLocation());
            System.out.println("上课时间：" + course.getTime());
            System.out.println("授课教师：" + course.getTeacher().getName());
        } else {
            System.out.println("暂无选课记录");
        }
        System.out.println();
    }

    public Course getCourse() { return course; }
}